const express = require('express');
const router = new express.Router();

router.get('/', async(req, res, next) => {
    const content = [];
    for(let i = 0; i < 100; i++) 
        content.push({
            id: `${i}`,
            code: `code${i}`,
            name: `name${i}`,
            productCategoryCode: 'productCategoryCode',
            description: 'description',
            length: 1.00,
            width: 1.00,
            height: 2.00,
            grossWeight: 20.00,
            netWeight: 120.01,
            unit: 'unit',
            usagePerCar: 20,
            minPackSize: 5,
            minOrderQuantity: 10,
            partReplacementCode: 'partReplacementCode',
            status: 1,
            rowVersion: 'string',
            partReplacements: [
                {
                    id: '1',
                    code: 'code001',
                    name: 'name001'
                },
            ],
            options: [
                'freeze',
                'thaw',
                'update',
            ]
        });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 100,
        }
    });
});

router.get('/forNoSubmitPart', (req, res) => {
    const data = [];
    for(let i = 1; i < 51; i++)
        data.push({
            id: `${i}`,
            code: `partCode${i}`,
            name: `partCame${i}`,
            unit: '个',
            minPackSize: i < 3 ? null : i,
            isOrderable: true,
            wholeSalePrice: 10000,
            retailGuidePrice: 11000,
        });
    const {pageIndex, pageSize} = req.query;
    res.json({
        message: 'ok',
        payload: {
            content: data,
            pageIndex: parseInt(pageIndex, 10),
            pageSize: parseInt(pageSize, 10),
            totalElements: 50
        }
    });
});

router.get('/forPartStockDealers', (req, res) => {
    const data = [];
    for(let i = 1; i < 51; i++)
        data.push({
            partId: `${i}`,
            partCode: `partCode${i}`,
            partName: `partName${i}`,
            productCategoryCode: `productCategoryCode${i}`,
            minPackSize: 10,
            minOrderQuantity: 11.00,
            unit: '个',
            usagePerCar: 10.00,
            status: 1,
        });
    const {pageIndex, pageSize} = req.query;
    res.json({
        message: 'ok',
        payload: {
            content: data,
            pageIndex: parseInt(pageIndex, 10),
            pageSize: parseInt(pageSize, 10),
            totalElements: 50
        }
    });
});

router.get('/forPartSaleOrder', (req, res) => {
    const data = [];
    for(let i = 1; i < 51; i++)
        data.push({
            id: `${i}`,
            code: `partCode${i}`,
            name: `partCame${i}`,
            unit: '个',
            minPackSize: i < 3 ? null : i,
            isOrderable: true,
            price: 869,
            quantity: 10,
            partReplacementCode: `${i}`,
            isType: true,
            isTransport: true
        });
    const {pageIndex, pageSize} = req.query;
    res.json({
        message: 'ok',
        payload: {
            content: data,
            pageIndex: parseInt(pageIndex, 10),
            pageSize: parseInt(pageSize, 10),
            totalElements: 50
        }
    });
});
router.get('/forPartSaleOrder/query', (req, res) => {
    const data = [];
    for(let i = 1; i < 10; i++)
        data.push({
            id: `${i}`,
            code: `partCode${i}`,
            name: `partCame${i}`,
            unit: '个',
            minPackSize: i < 3 ? null : i,
            isOrderable: true,
            price: 869,
            quantity: 10,
            partReplacementCode: `${i}`,
        });
    const {pageIndex, pageSize} = req.query;
    res.json({
        message: 'ok',
        payload: {
            content: data,
            pageIndex: parseInt(pageIndex, 10),
            pageSize: parseInt(pageSize, 10),
            totalElements: 50
        }
    });
});
router.get('/forHsCode', (req, res) => {
    const data = [];
    for(let i = 1; i < 51; i++)
        data.push({
            id: `${i}`,
            brandCode: '品牌01',
            code: `partCode${i}`,
            name: `partCame${i}`,
            specialName: `specialName${i}`,
            productCategoryCode: `productCategoryCode${i}`,
            partCategory: `partCategory${i}`,
            minPackSize: i < 3 ? null : i,
            overseaOnly: `overseaOnly${i}`
        });
    const {pageIndex, pageSize} = req.query;
    res.json({
        message: 'ok',
        payload: {
            content: data,
            pageIndex: parseInt(pageIndex, 10),
            pageSize: parseInt(pageSize, 10),
            totalElements: 50
        }
    });
});
router.post('/forPartSaleOrderImport', (req, res) => {
    const data = [];
    for(let i = 1; i < 51; i++)
        data.push({
            id: `${i}`,
            code: `partCode${i}`,
            name: `partCame${i}`,
            unit: '个',
            minPackSize: i < 3 ? null : i,
            isOrderable: true,
            price: 869,
            quantity: 10,
            planQuantity: 10,
            isColor: !(i % 2)
        });
    const {pageIndex, pageSize} = req.query;
    res.json({
        message: 'ok',
        payload: {
            content: data,
            pageIndex: parseInt(pageIndex, 10),
            pageSize: parseInt(pageSize, 10),
            totalElements: 50
        }
    });
});
router.get('/exportBasicData', (req, res) => {
    res.json({
        message: 'success',
        payload: 'Mock导出基础属性'
    });
});

router.get('/exportCheckedPopertiesData', (req, res) => {
    res.json({
        message: 'success',
        payload: 'Mock导出检查属性'
    });
});

router.get('/exportSalesAttributesPopertiesData', (req, res) => {
    res.json({
        message: 'success',
        payload: 'Mock导出销售属性'
    });
});

router.post('/checkAttributes/import', async(req, res, next) => {
    const data = {
        message: 'message'
    };
    res.json(data);
});

router.post('/salesAttributes/import', async(req, res, next) => {
    const data = {
        message: 'message'
    };
    res.json(data);
});
router.get('/salesAttributes/importTemp', (req, res) => {
    res.json({
        message: 'success',
        payload: 'Mock导入销售属性模板'
    });
});
router.get('/checkAttributes/importTemp', (req, res) => {
    res.json({
        message: 'success',
        payload: 'Mock导入检查属性模板'
    });
});

router.get('/forPartOrderPlan', (req, res) => {
    const data = [];
    for(let i = 1; i < 51; i++)
        data.push({
            id: `${i}`,
            code: `partCode${i}`,
            name: `partCame${i}`,
            unit: '个',
            productCategoryCode: '车型',
            minPackSize: 5,
            price: 10000,
        });
    res.json({
        message: 'ok',
        payload: {
            content: data,
            totalElements: 50
        }
    });
});

router.get('/:id', async(req, res, next) => {
    const data = {
        message: 'message',
        payload: {
            id: 'id126',
            code: 'code127',
            name: 'name128',
            specialName: 'specialName131',
            description: 'description',
            unit: 'unit',
            usagePerCar: 1,
            minPackSize: 1,
            productCategoryCode: 'productCategoryCode129',
            alternativePlan: 'alternativePlan',
            isConsume: 'isConsume',
            brandName: 'brandName130',
            changeFlag: 'changeFlag',
            shelfLife: 'shelfLife',
            safeMaterial: 'safeMaterial',
            supplierCode: 'supplierCode132',
            remark: 'remark',
            isOrderable: true,
            warrantyPartType: 1,
            wholeSalePrice: 1,
            retailGuidePrice: 1,
            overseaOnly: 'overseaOnly',
            partReplacementCode: '123',
            minOrderQuantity: 12,
            partCategory: 'PartCategory',
            leng: 22.25,
            width: 21.35,
            height: 20.51,
            grossWeight: 250.00,
            netWeight: 200.00,
            style: 'style',
            packageRule: 'packageRule',
            certificationMark: 'CertificationMark',
            isImported: 'IsImported',
            isDecimalAllowed: true,
            status: 1,
            operateTime: '2019',
            operatorName: 'zhangsan',
            part: 'xxx',
            chemicalCheck: false,
            airMagneticCheck: true,
            businessCheck: false,
            dangerousGoods: true,
            remoteControl: true,
            cvJointKit: true,
            rowVersion: 'rowVersion',
            options: [
            ],
            partSalesPrice: [
                {
                    id: '1',
                    brandCode: '001',
                    brandName: 'brandName',
                    beginDate: '2019',
                    endDate: '2020',
                    currency: 1,
                    type: 1,
                    price: '￥250',
                    isEstimated: true,
                    dealerCode: 'ASFASD,DASGA,DAGHFB',
                    estimatedPrice: 1200,
                },
                {
                    id: '2',
                    brandCode: '002',
                    brandName: 'brandName',
                    beginDate: '2020',
                    endDate: '2020',
                    currency: 2,
                    type: 2,
                    price: '￥250',
                    isEstimated: false,
                    dealerCode: 'ASFASD,DASGA,DAGHFB'
                }
            ],
            partSalesProperty: [
                {
                    id: '1',
                    brandId: '001',
                    brandCode: '001',
                    brandName: 'brandName1',
                    saleable: true,
                    remark: 'remark1',
                },
            ]
        }
    };
    res.json(data);
});
router.put('/freeze', (req, res) => {
    res.json({
        message: '冻结成功'
    });
});
router.put('/thaw', (req, res) => {
    res.json({
        message: '解冻成功'
    });
});
router.put('/:id', (req, res) => {
    res.json({
        message: '编辑成功'
    });
});
module.exports = router;

